//
// Created by antler on 2018/12/6.
//

#include "Size.h"

#include <new>

Size Size::ZERO = Size();
Size Size::INVALID = Size(-1, -1);

Size *Size::create() {
    return new(std::nothrow)Size();
}

Size *Size::createWith(int w, int h) {
    return new(std::nothrow)Size(w, h);
}

Size *Size::createWith(const Point &point) {
    return new(std::nothrow)Size(point.x, point.y);
}

Size *Size::createWith(const Size &size) {
    return new(std::nothrow)Size(size);
}

Size::Size() {
    width = 0;
    height = 0;
}

Size::Size(int w, int h) {
    width = w;
    height = h;
}

Size Size::operator+(const Size &size) const {
    return Size(width + size.width, height + size.height);
}

Size Size::operator-(const Size &size) const {
    return Size(width - size.width, height - size.height);
}

Size Size::operator*(int ratio) const {
    return Size(width * ratio, height * ratio);
}

Size Size::operator/(int ratio) const {
    return Size(width / ratio, height / ratio);
}

bool Size::operator==(const Size &size) const {
    return (width == size.width && height == size.height);
}

Size Size::operator-() const {
    return Size(-width, -height);
}
